using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace ProgramMain.Framework
{
    public partial class frmBaseModal : DevExpress.XtraEditors.XtraForm
    {
        public frmBaseModal()
        {
            InitializeComponent();

            this.Icon = GlobalData.DefaultIcon();
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
        }
        
        public static DialogResult ShowModal(BaseDetailCtl Ctl, string Caption, IButtonControl Accept, IButtonControl Cancel, BaseSecurity.SecurityActionType ActionType)
        {
            //if (Ctl.CheckSecurityAction(ActionType, true) != BaseSecurity.SuperBool.False)
            {
                frmBaseModal frmCommon = new frmBaseModal();
                frmCommon.Controls.Add(Ctl);
                frmCommon.AutoSize = true;
                Ctl.Dock = DockStyle.Fill;
                frmCommon.StartPosition = FormStartPosition.CenterParent;

                frmCommon.Text = Caption;

                frmCommon.AcceptButton = Accept;
                frmCommon.CancelButton = Cancel;
                //frmCommon.BringToFront();

                DialogResult res = frmCommon.ShowDialog(Program.MainForm);
                
                Program.MainForm.Activate();

                return res;
            }/*
            else
            {
                return DialogResult.Cancel;
            }*/
        }

        public static DialogResult ShowModal(BaseDetailCtl Ctl, string Caption, IButtonControl Accept, IButtonControl Cancel)
        {
            return ShowModal(Ctl, Caption, Accept, Cancel, BaseSecurity.SecurityActionType.Edit);
        }
    }
}